package com.droid.network.interceptor;

import android.content.Context;

import com.droid.network.base.INetworkRequiredInfo;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * @author zhyuc
 * @since 2019/9/24 18:48
 */
public class CommonResponseInterceptor implements Interceptor {

    private Context context;
    private INetworkRequiredInfo requiredInfo;

    public CommonResponseInterceptor(Context context, INetworkRequiredInfo requiredInfo) {
        this.context = context;
        this.requiredInfo = requiredInfo;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response builder = chain.proceed(chain.request());

       /* if (!builder.headers("Set-Cookie").isEmpty()) {
            HashSet<String> cookies = new HashSet<>();

            for (String header : builder.headers("Set-Cookie")) {
                cookies.add(header);
            }

            if (context != null) {
                context.getSharedPreferences(PersistentCookieStore.COOKIE_PREFS, Context.MODE_PRIVATE)
                        .edit().putStringSet(chain.request().url().host(), cookies).apply();
            }
        }*/

        return builder;
    }
}
